<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../template/DefaultTemplate.xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="top">
        Account activation
    </ui:define>

    <ui:define name="content">
        <style>
            .ars td {
                display: block;
            }
        </style>
        <h:form>
            <h:panelGroup layout="block" rendered="#{loginManagerBean.accountValid}">
                <p>Please reset password and set up secure question to activate your account.</p>
                <p>If you skip this step, you account will still be disabled.</p>
                <p:panel>
                    <h:panelGrid columns="3" cellpadding="10">
                        <h:outputLabel value="Old password"/>
                        <h:inputSecret required="true" requiredMessage="Please input your old password."
                                       id="oldpwd" value="#{loginManagerBean.oldPassword}"
                                       validator="#{loginManagerBean.checkOldPassword}"/>
                        <p:message for="oldpwd"/>

                        <h:outputLabel for="initPwd" value="New Password: "/>
                        <p:password id="initPwd" value="#{loginManagerBean.newPassword}" 
                                    required="true" requiredMessage="Please reset your password." feedback="true" minLength="6">
                            <f:validateLength minimum="6" maximum="20" />
                        </p:password>
                        <p:message for="initPwd"/>
                    </h:panelGrid>
                </p:panel>
                <p:panel>
                    <h:outputLabel for="secQns" value="Secure Question: "/>
                    <h:selectOneRadio id="secQns" styleClass="ars" value="#{loginManagerBean.sua.question1}" required="true" requiredMessage="Please select one secure question.">
                        <f:selectItem itemLabel="What's your mother's name?" itemValue="What's your mother's name?"/>
                        <f:selectItem itemLabel="Where were you when you had your first kiss?" itemValue="Where were you when you had your first kiss?"/>
                        <f:selectItem itemLabel="What was your childhood nickname?" itemValue="What was your childhood nickname?"/>
                        <f:selectItem itemLabel="What was the name of your primary school?" itemValue="What was the name of your primary school?"/>
                        <f:selectItem itemLabel="What is your favorite color?" itemValue="What is your favorite color?"/>
                    </h:selectOneRadio>
                    <p:message for="secQns"/>
                </p:panel>
                <p:panel>
                    <h:panelGrid columns="3" cellpadding="10">
                        <h:outputLabel for="secAns" value="Answer: "/>
                        <h:inputText id="secAns" value="#{loginManagerBean.sua.answer1}" required="true" requiredMessage="Please input your secure question's answer."/>
                        <p:message for="secAns"/>
                    </h:panelGrid>
                </p:panel>
                <p:commandButton ajax="false" id="resetBtn" value="Submit" action="#{loginManagerBean.activateAccount}" />
            </h:panelGroup>

            <h:panelGroup layout="block" rendered="#{!loginManagerBean.accountValid}">
                <p>Activation failed! Sorry, you are not authorized.</p> 
                <p:commandButton ajax="false" id="redirectBtn" value="Go back to Log in Page" action="/LoginAdmin/login?faces-redirect=true"/>
            </h:panelGroup>
        </h:form>
    </ui:define>

    <ui:define name="bottom">

    </ui:define>

</ui:composition>
